package com.niit.web.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.niit.bean.Note;
import com.niit.bean.NoteRepo;
import com.niit.bean.User;
import com.niit.service.NoteRepoService;
import com.niit.service.NoteService;
import com.niit.service.impl.NoteRepoServiceImpl;
import com.niit.service.impl.NoteServiceImpl;

@WebServlet("/UpdateNoteController")
public class UpdateNoteController extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String id = request.getParameter("id");
		NoteService ns = new NoteServiceImpl();
		Note note = ns.findNoteById(id);
		
		User user = (User) request.getSession().getAttribute("user");
		
		NoteRepoService nrs = new NoteRepoServiceImpl();
		List<NoteRepo> list = nrs.findReposByUser(user);
		
		request.setAttribute("repos", list);
		request.setAttribute("note", note);
		request.getRequestDispatcher("/jsp/user/notebook/notebookedit.jsp").forward(request, response);
	}

}
